[libc++] Fix error flags and exceptions propagated from input stream operations Summary: This is a re-application of r357533 and r357531. They had been reverted because we thought the commits broke the LLDB data formatters, but it turns out this was because only r357531 had been included in the CI run. Before this patch, we would only ever throw an exception if the badbit was set on the stream. The Standard is currently very unclear on how exceptions should be propagated and what error flags should be set by the input stream operations. This commit changes libc++ to behave under a different (but valid) interpretation of the Standard. This interpretation of the Standard matches what other implementations are doing. This effectively implements the wording in p1264r0. It hasn't been voted into the Standard yet, however there is wide agreement that the fix is correct and it's just a matter of time before the fix is standardized. PR21586 PR15949 rdar://problem/15347558 Reviewers: mclow.lists, EricWF Subscribers: christof, dexonsmith, cfe-commits Differential Revision: https://reviews.llvm.org/D49863 git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@357775 91177308-0d34-0410-b5e6-96231b3b80d8 
diff --git a/include/ios b/include/ios index 96e84eb..ce4e176 100644 --- a/include/ios +++ b/include/ios 
@@ -330,6 +330,15 @@  void __set_badbit_and_consider_rethrow();  void __set_failbit_and_consider_rethrow();   + _LIBCPP_INLINE_VISIBILITY + void __setstate_nothrow(iostate __state) + { + if (__rdbuf_) + __rdstate_ |= __state; + else + __rdstate_ |= __state | ios_base::badbit; + } +  protected:  _LIBCPP_INLINE_VISIBILITY  ios_base() {// purposefully does no initialization